Skip to content

Date validations#13596

Merged
KarnaiahPesula merged 1 commit into
developmentfrom
bugfix-13452-exposure-date-issue-in-epi-form
Sep 11, 2025
Merged

Date validations#13596
KarnaiahPesula merged 1 commit into
developmentfrom
bugfix-13452-exposure-date-issue-in-epi-form

Conversation

@KarnaiahPesula

@KarnaiahPesula KarnaiahPesula commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #

Summary by CodeRabbit

  • Bug Fixes
    • Enforced start/end date validation in Activity as Case and Exposure forms, preventing end dates earlier than start dates.
    • Provides immediate feedback on invalid date ranges to reduce data entry errors and improve data quality.

@KarnaiahPesula KarnaiahPesula linked an issue Sep 11, 2025 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Sep 11, 2025

Copy link
Copy Markdown

Walkthrough

Introduces explicit start/end date field creation and cross-field validation in ActivityAsCaseForm and ExposureForm using DateComparisonValidator. START_DATE and END_DATE are excluded from bulk field addition and validated as a pair to enforce start-before-end constraints.

Changes

Cohort / File(s) Summary of Changes
Activity-as-Case date validation refactor
sormas-ui/src/main/java/de/symeda/sormas/ui/ActivityAsCase/ActivityAsCaseForm.java
Explicitly create START_DATE and END_DATE as DateField instances; attach cross-field validators via DateComparisonValidator.addStartEndValidators; remove these fields from the bulk addBasicFields list; HTML layout references unchanged.
Exposure form date validation
sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java
Retrieve START_DATE and END_DATE DateTimeField instances explicitly and apply DateComparisonValidator.addStartEndValidators; replaces prior bulk field handling for these two fields; no other logic altered.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant F as UI Form (ActivityAsCase/Exposure)
  participant S as START_DATE Field
  participant E as END_DATE Field
  participant V as DateComparisonValidator

  U->>F: Open form / edit dates
  F->>S: Initialize/get startDate
  F->>E: Initialize/get endDate
  F->>V: addStartEndValidators(S, E)
  Note right of V: Cross-field constraint registered

  U->>F: Submit or change date values
  F->>V: Validate(S.value, E.value)
  alt start after end or invalid range
    V-->>F: Validation error(s)
    F-->>U: Show error on START_DATE/END_DATE
  else valid range
    V-->>F: OK
    F-->>U: Accept values / proceed
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (1 passed, 2 warnings)

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The current description contains only the repository template and "Fixes #" with no issue number, no summary of what changed, no rationale, and no testing or impact information, so it is incomplete and does not meet the repository's expectations for a PR description. Please update the description by adding the issue number after "Fixes #", a concise summary of the changes (e.g., which files were modified and that start/end date cross-field validators were added), the reason for the change and any behavioral impact, and clear testing steps or expected validation behavior so reviewers can verify the fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Date validations" is concise and directly related to the main change in this PR—adding start/end date cross-field validation in ActivityAsCaseForm and ExposureForm—so it accurately summarizes the primary intent of the changeset.

Poem

I hop between the dates with care,
Ensuring starts precede their pair.
Two fields dance, a tidy line—
Validator says, “They’re fine!”
With whiskers twitching, I approve the flow,
From start to end, we’re good to go. 🐇⏳

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62a626d and 175eaac.

📒 Files selected for processing (2)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/ActivityAsCase/ActivityAsCaseForm.java (3 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: SORMAS CI
🔇 Additional comments (4)
sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java (2)

66-66: Import addition is appropriate.

DateComparisonValidator import aligns with the new cross-field validation.


223-227: Start/end DateTime validation verified — accepts DateTimeField, null-safe, equality allowed.

  • DateComparisonValidator operates on Field so DateTimeField is accepted.
  • isValidValue returns true if either date or reference is null (null-safe).
  • Equality is allowed (validators use <= / >=).
  • addStartEndValidators(start,end) defaults to dateOnly=true (time is ignored); call the 3-arg overload with dateOnly=false for time-aware validation.
sormas-ui/src/main/java/de/symeda/sormas/ui/ActivityAsCase/ActivityAsCaseForm.java (2)

43-43: Imports look correct.

DateField and DateComparisonValidator imports match the new usage.

Also applies to: 64-64


125-129: Start/end Date validation: inclusive and null-safe.

  • Validator returns true if either value is null (no error when one field is empty).
  • Start uses <= and end uses >=, so start == end is allowed.
  • addStartEndValidators(start, end) defaults to dateOnly = true (date-only comparison).
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-13452-exposure-date-issue-in-epi-form

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sormas-vitagroup

Copy link
Copy Markdown
Contributor

@KarnaiahPesula KarnaiahPesula merged commit 7e8bd31 into development Sep 11, 2025
8 of 10 checks passed
@KarnaiahPesula KarnaiahPesula deleted the bugfix-13452-exposure-date-issue-in-epi-form branch September 11, 2025 08:32
@coderabbitai coderabbitai Bot mentioned this pull request Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exposure date in Epi data can be unrealistic

3 participants